package cn.hou.java.designpattern._18memento;

import java.util.ArrayList;
import java.util.List;

//需要记住状态的对象
public class Person{
	private String name; //状态
	private String age; //状态
	//提供备份,回滚方法
	public Memento backup(){
		return new Memento(name,age);
	}
	//回滚,即将备份对象中的属性还原回来
	public void rollBack(Memento memento){
		this.name=memento.getName();
		this.age=memento.getAge();
	}
	public Person(String name, String age) {
		this.name = name;
		this.age = age;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getAge() {
		return age;
	}
	public void setAge(String age) {
		this.age = age;
	}
	
	@Override
	public String toString() {
		return "Person [name=" + name + ", age=" + age + "]";
	}
}
